\(\int \frac {\csc (x)}{1+\tan (x)} \, dx\) [78]

   Optimal result
   Rubi [A] (verified)
   Mathematica [C] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F]
   Maxima [B] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 9, antiderivative size = 26 \[ \int \frac {\csc (x)}{1+\tan (x)} \, dx=-\text {arctanh}(\cos (x))+\frac {\text {arctanh}\left (\frac {\cos (x)-\sin (x)}{\sqrt {2}}\right )}{\sqrt {2}} \]

[Out]

-arctanh(cos(x))+1/2*arctanh(1/2*(cos(x)-sin(x))*2^(1/2))*2^(1/2)

Rubi [A] (verified)

Time = 0.09 (sec) , antiderivative size = 26, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 5, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.556, Rules used = {3599, 3189, 3855, 3153, 212} \[ \int \frac {\csc (x)}{1+\tan (x)} \, dx=\frac {\text {arctanh}\left (\frac {\cos (x)-\sin (x)}{\sqrt {2}}\right )}{\sqrt {2}}-\text {arctanh}(\cos (x)) \]

[In]

Int[Csc[x]/(1 + Tan[x]),x]

[Out]

-ArcTanh[Cos[x]] + ArcTanh[(Cos[x] - Sin[x])/Sqrt[2]]/Sqrt[2]

Rule 212

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[-b, 2]))*ArcTanh[Rt[-b, 2]*(x/Rt[a, 2])], x]
 /; FreeQ[{a, b}, x] && NegQ[a/b] && (GtQ[a, 0] || LtQ[b, 0])

Rule 3153

Int[(cos[(c_.) + (d_.)*(x_)]*(a_.) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> Dist[-d^(-1), Subst[Int
[1/(a^2 + b^2 - x^2), x], x, b*Cos[c + d*x] - a*Sin[c + d*x]], x] /; FreeQ[{a, b, c, d}, x] && NeQ[a^2 + b^2,
0]

Rule 3189

Int[(cos[(c_.) + (d_.)*(x_)]^(m_.)*sin[(c_.) + (d_.)*(x_)]^(n_.))/(cos[(c_.) + (d_.)*(x_)]*(a_.) + (b_.)*sin[(
c_.) + (d_.)*(x_)]), x_Symbol] :> Int[ExpandTrig[cos[c + d*x]^m*(sin[c + d*x]^n/(a*cos[c + d*x] + b*sin[c + d*
x])), x], x] /; FreeQ[{a, b, c, d, m, n}, x] && IntegersQ[m, n]

Rule 3599

Int[sin[(e_.) + (f_.)*(x_)]^(m_.)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(n_.), x_Symbol] :> Int[Sin[e + f*x]^
m*((a*Cos[e + f*x] + b*Sin[e + f*x])^n/Cos[e + f*x]^n), x] /; FreeQ[{a, b, e, f}, x] && IntegerQ[(m - 1)/2] &&
 ILtQ[n, 0] && ((LtQ[m, 5] && GtQ[n, -4]) || (EqQ[m, 5] && EqQ[n, -1]))

Rule 3855

Int[csc[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-ArcTanh[Cos[c + d*x]]/d, x] /; FreeQ[{c, d}, x]

Rubi steps \begin{align*} \text {integral}& = \int \frac {\cot (x)}{\cos (x)+\sin (x)} \, dx \\ & = \int \left (\csc (x)+\frac {1}{-\cos (x)-\sin (x)}\right ) \, dx \\ & = \int \csc (x) \, dx+\int \frac {1}{-\cos (x)-\sin (x)} \, dx \\ & = -\text {arctanh}(\cos (x))-\text {Subst}\left (\int \frac {1}{2-x^2} \, dx,x,-\cos (x)+\sin (x)\right ) \\ & = -\text {arctanh}(\cos (x))-\frac {\text {arctanh}\left (\frac {-\cos (x)+\sin (x)}{\sqrt {2}}\right )}{\sqrt {2}} \\ \end{align*}

Mathematica [C] (verified)

Result contains complex when optimal does not.

Time = 0.12 (sec) , antiderivative size = 41, normalized size of antiderivative = 1.58 \[ \int \frac {\csc (x)}{1+\tan (x)} \, dx=(1+i) (-1)^{3/4} \text {arctanh}\left (\frac {-1+\tan \left (\frac {x}{2}\right )}{\sqrt {2}}\right )-\log \left (\cos \left (\frac {x}{2}\right )\right )+\log \left (\sin \left (\frac {x}{2}\right )\right ) \]

[In]

Integrate[Csc[x]/(1 + Tan[x]),x]

[Out]

(1 + I)*(-1)^(3/4)*ArcTanh[(-1 + Tan[x/2])/Sqrt[2]] - Log[Cos[x/2]] + Log[Sin[x/2]]

Maple [A] (verified)

Time = 0.37 (sec) , antiderivative size = 26, normalized size of antiderivative = 1.00

method result size
default \(\ln \left (\tan \left (\frac {x}{2}\right )\right )-\sqrt {2}\, \operatorname {arctanh}\left (\frac {\left (2 \tan \left (\frac {x}{2}\right )-2\right ) \sqrt {2}}{4}\right )\) \(26\)
risch \(\ln \left ({\mathrm e}^{i x}-1\right )-\frac {\sqrt {2}\, \ln \left ({\mathrm e}^{i x}-\frac {\sqrt {2}}{2}+\frac {i \sqrt {2}}{2}\right )}{2}+\frac {\sqrt {2}\, \ln \left ({\mathrm e}^{i x}+\frac {\sqrt {2}}{2}-\frac {i \sqrt {2}}{2}\right )}{2}-\ln \left ({\mathrm e}^{i x}+1\right )\) \(66\)

[In]

int(csc(x)/(1+tan(x)),x,method=_RETURNVERBOSE)

[Out]

ln(tan(1/2*x))-2^(1/2)*arctanh(1/4*(2*tan(1/2*x)-2)*2^(1/2))

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 55 vs. \(2 (24) = 48\).

Time = 0.26 (sec) , antiderivative size = 55, normalized size of antiderivative = 2.12 \[ \int \frac {\csc (x)}{1+\tan (x)} \, dx=\frac {1}{4} \, \sqrt {2} \log \left (\frac {2 \, {\left (\sqrt {2} + \cos \left (x\right )\right )} \sin \left (x\right ) - 2 \, \sqrt {2} \cos \left (x\right ) - 3}{2 \, \cos \left (x\right ) \sin \left (x\right ) + 1}\right ) - \frac {1}{2} \, \log \left (\frac {1}{2} \, \cos \left (x\right ) + \frac {1}{2}\right ) + \frac {1}{2} \, \log \left (-\frac {1}{2} \, \cos \left (x\right ) + \frac {1}{2}\right ) \]

[In]

integrate(csc(x)/(1+tan(x)),x, algorithm="fricas")

[Out]

1/4*sqrt(2)*log((2*(sqrt(2) + cos(x))*sin(x) - 2*sqrt(2)*cos(x) - 3)/(2*cos(x)*sin(x) + 1)) - 1/2*log(1/2*cos(
x) + 1/2) + 1/2*log(-1/2*cos(x) + 1/2)

Sympy [F]

\[ \int \frac {\csc (x)}{1+\tan (x)} \, dx=\int \frac {\csc {\left (x \right )}}{\tan {\left (x \right )} + 1}\, dx \]

[In]

integrate(csc(x)/(1+tan(x)),x)

[Out]

Integral(csc(x)/(tan(x) + 1), x)

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 50 vs. \(2 (24) = 48\).

Time = 0.29 (sec) , antiderivative size = 50, normalized size of antiderivative = 1.92 \[ \int \frac {\csc (x)}{1+\tan (x)} \, dx=\frac {1}{2} \, \sqrt {2} \log \left (-\frac {\sqrt {2} - \frac {\sin \left (x\right )}{\cos \left (x\right ) + 1} + 1}{\sqrt {2} + \frac {\sin \left (x\right )}{\cos \left (x\right ) + 1} - 1}\right ) + \log \left (\frac {\sin \left (x\right )}{\cos \left (x\right ) + 1}\right ) \]

[In]

integrate(csc(x)/(1+tan(x)),x, algorithm="maxima")

[Out]

1/2*sqrt(2)*log(-(sqrt(2) - sin(x)/(cos(x) + 1) + 1)/(sqrt(2) + sin(x)/(cos(x) + 1) - 1)) + log(sin(x)/(cos(x)
 + 1))

Giac [A] (verification not implemented)

none

Time = 0.36 (sec) , antiderivative size = 44, normalized size of antiderivative = 1.69 \[ \int \frac {\csc (x)}{1+\tan (x)} \, dx=\frac {1}{2} \, \sqrt {2} \log \left (\frac {{\left | -2 \, \sqrt {2} + 2 \, \tan \left (\frac {1}{2} \, x\right ) - 2 \right |}}{{\left | 2 \, \sqrt {2} + 2 \, \tan \left (\frac {1}{2} \, x\right ) - 2 \right |}}\right ) + \log \left ({\left | \tan \left (\frac {1}{2} \, x\right ) \right |}\right ) \]

[In]

integrate(csc(x)/(1+tan(x)),x, algorithm="giac")

[Out]

1/2*sqrt(2)*log(abs(-2*sqrt(2) + 2*tan(1/2*x) - 2)/abs(2*sqrt(2) + 2*tan(1/2*x) - 2)) + log(abs(tan(1/2*x)))

Mupad [B] (verification not implemented)

Time = 4.56 (sec) , antiderivative size = 38, normalized size of antiderivative = 1.46 \[ \int \frac {\csc (x)}{1+\tan (x)} \, dx=\ln \left (\mathrm {tan}\left (\frac {x}{2}\right )\right )-\sqrt {2}\,\mathrm {atanh}\left (\frac {5\,\sqrt {2}\,\mathrm {tan}\left (\frac {x}{2}\right )+2\,\sqrt {2}}{7\,\mathrm {tan}\left (\frac {x}{2}\right )+3}\right ) \]

[In]

int(1/(sin(x)*(tan(x) + 1)),x)

[Out]

log(tan(x/2)) - 2^(1/2)*atanh((5*2^(1/2)*tan(x/2) + 2*2^(1/2))/(7*tan(x/2) + 3))